package com.gitee.melin.bee.core.jdbc.parser;

import com.google.common.collect.Maps;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;

public interface ConnectionURLParser {
    JdbcURLInfo parse(final String url);

    default Map<String, String> parserOptions(String options) {
        Map<String, String> map = Maps.newHashMap();
        if (StringUtils.isBlank(options)) {
            return map;
        }

        String[] items = StringUtils.split(options, "&");
        for (String item : items) {
            String[] arr = StringUtils.split(item, "=");
            map.put(arr[0], arr[1]);
        }

        return map;
    }
}
